#include "head.h"
int main(int argc, char *argv[])
{
    // ./00_client 192.168.72.128 12345
    ARGS_CHECK(argc,3);
    int sockfd = socket(AF_INET,SOCK_STREAM,0);
    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(atoi(argv[2]));
    addr.sin_addr.s_addr = inet_addr(argv[1]);
    int ret = connect(sockfd,(struct sockaddr *)&addr,sizeof(addr));
    ERROR_CHECK(ret,-1,"connect");
    char c=' ';
	while (1) {
printf("请选择登录/注册,请摁n/y\n");
		 int success=0;

		while ((c = getchar()) == '\n' || c == ' ');
		if (c == 'y' || c == 'Y') {
			printf("注册开始\n");
	register_user(sockfd,&success);
			if(success==1)
			break;
		}
		else if (c == 'n' || c == 'N')
		{
			printf("登陆开始\n");
 signin_user(sockfd, &success);

if(success==1)
			break;
		}
		else{
		printf("error,请重试\n");
		while (getchar() != '\n');
		
        }
printf("success=%d\n",success);
	}
    return 0;
}


